﻿@section HtmlHead{
}
<div class="contentpage-outerdiv">
    <h2>@ViewBag.PageTitle</h2>
    <span class="field-validation-error">&nbsp;@Html.ValidationSummary("Create was unsuccessful. Please correct the errors and try again.") 
    @ViewBag.Message</span>
     @using (Html.BeginForm("CreateWeightedContent", "BackOffice", FormMethod.Post, new { id = "form1" }))
       {
    <fieldset>
        <legend>Weighted Content Fields</legend>
        <p>
            <label for="Title">Title:</label>
            @Html.TextBox("Title", "", new { @class = "required" })
        </p>
        <p>
            <label for="TargetDiv">Target Div:</label>
            @Html.TextBox("TargetDiv", "", new { @class = "required" })
        </p>
        <p>
            <label for="IsModuleType">Is Module Type:</label>
            @Html.CheckBox("IsModuleType", false, new { onclick = "ToggleModuleOptions();", autocomplete = "off" })
        </p>
        <div id="widget-options">
            <p>
                <label for="ZoneName">Zone Name:</label>
                @Html.TextBox("ZoneName", "")
            </p>
        </div>
        <div style="display:none;" id="module-options">
            <p>
                <label for="IntervalSeconds">Interval Seconds:</label>
                @Html.TextBox("IntervalSeconds")
            </p> 
            <p>
                <label for="FirstTransitionDelay">First Transition Delay:</label>
                @Html.TextBox("FirstTransitionDelay")
            </p>
        </div>
        <p>
            <label for="Description">Description:</label>
            @Html.TextArea("Description")
        </p>
        <p>
            <label for="ContainerClasses">Container Classes:</label>
            @Html.TextBox("ContainerClasses")
        </p>
        <p>
            <label for="Active">Active:</label>
            @Html.CheckBox("Active")
        </p>                                                                                              
        <p>
            <input type="button" onclick="SubmitForm();" value="Create" />
        </p>
    </fieldset>
     } 
    <div>
        @Html.ActionLink("Back to List", "ManageWeightedContent")
    </div>
</div> 
@section ScriptContent{
<script src="@Url.Content("/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script type="text/javascript" >
    var isForModule = false;
    function SubmitForm() {
        if (!isForModule) {
            $("#form1").submit();
        }
        else {
            var targetDivVal = $("#TargetDiv").val();
            if (!targetDivVal) { alert("targetdiv is required"); }
            return false;
        }
    }
    function ToggleModuleOptions() {
        if (isForModule) { isForModule = false; } else { isForModule = true; }
        $("#module-options").toggle();
        $("#widget-options").toggle();
    }   
</script>
}
